<?php require_once "menu.php"; ?>
    <script type="text/javascript">
    	$().ready(function() {
            $("#ticketForm").validate({
                errorLabelContainer: $("#ticketForm div.error")
            });
        });
    </script>

    <style type="text/css">
        .ticketForm fieldset p.error label { color: red; }
        form.ticketForm label.error {
            display: block;
            margin-left: 1em;
            width: auto;
        }
        div.error {
            background-color: #eee;
            border: 1px dashed red;
            margin: 5px;
            padding: 10px;
        }

        select {
            height: 20px;
            font-size: 14px;
        }
    </style>

<form id="ticketForm" name="ticketForm" action="<?php echo $html->url('/ticket/assignto/'.$ticket_details['ticketId']); ?>" method="post">
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%"><div class="pathway"></div></td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" href="javascript: document.getElementById('flag').value='back'; submitthis();">
                        <?php echo $html->image('admin/restore_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Back
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br/>
<br/>
<div align="center" class="centermain">
    <div class="main">

        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Assign Ticket</th>
            </tr>
        </table>

        <table class="adminform">
            <tr>
                <td width="60%" valign="top">
                    <table class="adminlist" cellpadding="20">
                        <table class="adminlist" cellpadding="20">
                            <tr>
                                <th colspan="2">Ticket Information</th>
                            </tr>
                            <tr>
                                <td width="100px">Date Created</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo date('M d, Y', strtotime($ticket_details['date_added'])); ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Date Reported</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo date('M d, Y', strtotime($ticket_details['date_reported'])); ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Category</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticket_details['category']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Item</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticket_details['item']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Department</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticket_details['department']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Location</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticket_details['location']['Extra']['value']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label">Subject</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;">
                                    <?php echo $ticket_details['subject']; ?>
                                </td>
                            </tr>
                            <tr>
                                <td id="input_label" valign="top">Details</td>
                                <td style="border: 1px dotted #ccc; background-color: #efefef;" valign="top">
                                    <p align="left"><?php echo $ticket_details['details']; ?></p>
                                </td>
                            </tr>
                    </table>
                </td>
                <td width="40%" valign="top">
                    <table class="adminlist" cellpadding="20">
                        <tr>
                            <th>Tech. Support Engineers</th>
                        </tr>
                        <tr>
                            <td class="subheader">Engineer's Name</td>
                        </tr>
                        <tr>
                            <td align="center" style="border: 1px dotted #ccc; background-color: #efefef;" valign="top">
                                <?php echo $form->select('assign.name', $engr_list, null, array('style' => 'width: 99%', 'title' => 'Please specify to whom this ticket will be assigned', 'class' => '{required:true}')); ?>
                            </td>
                        </tr>
                        <tr>
                            <td align="center" style="border: 1px dotted #ccc; background-color: #efefef;" valign="top">
                                <textarea name="data[assign][remarks]" rows="10" cols="" style="width: 99%;"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                <input type="submit" value="Assign" class="button" style="width: 99%; height: 25px;" />
                                <input type="hidden" id="ticketId" name="data[assign][ticketId]" value="<?php echo $ticket_details['ticketId']; ?>">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</div>
<input type="hidden" id="flag" name="data[flag]" />
</form>

<script type="text/javascript">
function submitthis()
{
    var flag = document.getElementById('flag').value;
    switch (flag) {
        default:
            document.ticketForm.submit();
        break;
    }
}

function checkmsg()
{
    var msg = '<?php echo $msg; ?>';
    if (msg) {
        alert(msg);
    }
}

checkmsg();
</script>